<?php
//协助人筛选条件

namespace App\Repositories\Filter;

class AssistantFilter
{

    /**
     * 处理查询条件
     * @param $query
     * @return array[]
     */
    public static function handleQuery($query = [])
    {
        $where = [];
        $whereIn = [];
        if (!empty($query['id'])) {
            $where[] = ['id', $query['id']];
        }
        if (!empty($query['ids'])) {
            $whereIn[] = ['id', $query['ids']];
        }
        if (!empty($query['activity_id'])) {
            $where[] = ['activity_id', $query['activity_id']];
        }
        if (!empty($query['name_keyword'])) {
            $where[] = ['name', 'like', "%{$query['name_keyword']}%"];
        }
        if (!empty($query['id_number'])) {
            $where[] = ['id_number', $query['id_number']];
        }
        if (!empty($query['id_numbers'])) {
            $whereIn[] = ['id_number', $query['id_numbers']];
        }
        if (!empty($query['mobile'])) {
            $where[] = ['mobile', $query['mobile']];
        }
        if (!empty($query['real_id'])) {
            $where[] = ['real_id', $query['real_id']];
        }
        if (!empty($query['real_ids'])) {
            $whereIn[] = ['real_id', $query['real_ids']];
        }
        if (!empty($query['gender'])) {
            $where[] = ['gender', $query['gender']];
        }
        if (!empty($query['birthday_gte'])) {
            $where[] = ['birthday', '>=', $query['birthday_gte']];
        }
        if (!empty($query['birthday_lt'])) {
            $where[] = ['birthday', '<', $query['birthday_lt']];
        }

        return [
            'where'   => $where,
            'whereIn' => $whereIn,

        ];
    }

}